import dayjs from 'dayjs'
import { debounce } from 'lodash-es'
import { useSnippetsStore } from '@renderer/stores'

export function useDateTime () {
  const setSnippets = useSnippetsStore(state => state.setSnippets)

  const getDateTime = debounce((format?: string) => {
    setSnippets([
      {
        id: 0, 
        title: 'datetime',
        content: dayjs().format(format || 'YYYY-MM-DD HH:mm:ss'),
        category_id: 0,
        created_at: '',
      },
    ])
  }, 500)

  return {
    getDateTime,
  }
}
